<!--<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="path" value="${pageContext.request.contextPath}" />-->
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>供应商管理</title>

<link rel="stylesheet" type="text/css"
	href="/Medical_Instrument/statics/h-ui/css/H-ui.min.css" />
<style type="text/css">
* {
	margin: 0;
	padding: 0;
}

h2 {
	font-weight: 500;
	text-align: center;
	padding: 30px 0 40px;
	border-bottom: 1px solid #92A5C7;
	background: linear-gradient(#F3F8FF, #E2EEFF, #BCD9FF);
}

.buttons {
	display: inline-block;
	font-size: 14px;
	border-radius: 10px 10px 0 0;
	border: 1px solid #9DA0A4;
	padding: 4px;
	text-align: center;
	background: linear-gradient(#DEECFF, #CAE1FF, #B6D6FF);
	color: #1E90FF;
	padding: 0 5px;
	height: 25px;
	line-height: 25px;
}

.but-width {
	width: 100px;
}

.div-width {
	width: 120px;
}

.buttons:hover {
	cursor: pointer;
	background: linear-gradient(#B6D6FF, #CAE1FF, #DEECFF);
}

.nav_span {
	margin-top: -27px;
}

.div_button {
	width: 120px;
	float: right;
	margin: 50px 40px 0 0;
}

.div_button li {
	margin-bottom: 10px;
	height: 27px;
}

.div_table {
	width: 1450px;
	display: inline-block;
	overflow: auto;
	margin: 30px 0 30px 30px;
	border: 5px solid #1E90FF;
	padding: 20px;
	height: 600px;
}

.back-color {
	background-color: red;
}

/* 停用颜色示例*/
.subclass-color td {
	color: red;
}
</style>
<script type="text/javascript"
	src="/Medical_Instrument/statics/lib/jquery/1.9.1/jquery.min.js"></script>
</head>

<body>
	<div style="width: 1723px">
		<div class="div-nav">
			<h2>供应商管理</h2>
		</div>
		<div style="width: 100%;">
			<div class="div_table cont_right">
				<table id="providerList_table"
					class="table table-border table-bordered table-bg" width="4500">
					<thead>
						<tr class="text-c">
							<th>供方编号</th>
							<th>名称</th>
							<th>全称</th>
							<th>拼音码</th>
							<th>供方编码</th>
							<th>地址</th>
							<th>联系人</th>
							<th>联系电话</th>
							<th>应付额</th>
							<th>应收额</th>
							<th>账号</th>
							<th>开户行</th>
							<th>税号</th>
							<th>是否审核</th>
							<th>公司电话</th>
							<th>邮政编码</th>
							<th>法人</th>
							<th>许可证编号</th>
							<th>营业执照编号</th>
							<th>经营方式</th>
							<th>质量机构负责人</th>
							<th>质量机构人数</th>
							<th>质量机构联系方式</th>
							<th>许可证有效期</th>
							<th>营业执照有效期</th>
							<th>认证证书有效期</th>
							<th>委托书有效期</th>
							<th>质保协议有效期</th>
							<th>器械许可证有效期</th>
							<th>质管停用</th>
						</tr>
					</thead>
					<tbody>
					</tbody>
				</table>
			</div>
			<div class="div_button">
				<ul>
					<li class="div-width"><span class="buttons div-width"
						style="border-radius: 10px; " onclick="startUsing()">启用</span></li>
					<li class="div-width"><span class="buttons div-width"
						style="border-radius: 10px; " onclick="blockUp()">停用</span></li>
					<li class="div-width"><span class="buttons div-width"
						style="border-radius: 10px; " onclick="blockUpAll()">全部停用</span></li>
					<li class="div-width"
						style="font-size: 15px;color: red;text-align: center;position: absolute;bottom: 50px;">红色表示已停用</li>
				</ul>
			</div>
		</div>
	</div>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/lib/layer/2.4/layer.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/h-ui/js/H-ui.min.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/h-ui.admin/js/H-ui.admin.js"></script>


	<script type="text/javascript"
		src="/Medical_Instrument/statics/lib/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript"
		src="/Medical_Instrument/statics/js/gsp/business_manage/moment.js"></script>
	<script type="text/javascript">
		$(function() {
             init();
			

			$('#providerList_table tbody').on(
					'click',
					'tr',
					function() {
						if ($(this).hasClass('selected')) {
							$(this).removeClass('selected');
						} else {
							$('#providerList_table tr.selected').removeClass(
									'selected');
							$(this).addClass('selected');
						}
					});

			$('.cont_right').scroll(
					function() {
						var obj = $(this);
						var value = obj.scrollLeft();

						$('#providerList_table_info').css('margin-left',
								(value + 'px'));
						$('#providerList_table_length').css('margin-left',
								(value + 'px'));

						$('#providerList_table_paginate').css('margin-right',
								('-' + value + 'px'));
						$('#providerList_table_filter').css('margin-right',
								('-' + value + 'px'));
					});
		});
		
		function init() {
		  $("#providerList_table").dataTable().fnDestroy();
				$("#providerList_table")
						.dataTable(
								{
									"processing" : true,
									"serverSide" : false,
									"paginationType" : "full_numbers",
									"ajax" : "${pageContext.request.contextPath}/firstEnterprise/getProviderList",
									"aaSorting" : [ [ 0, "desc" ] ],
									"aoColumnDefs" : [
											{
												"orderable" : false,
												"aTargets" : [ 1, 2, 3, 4, 5,
														6, 7, 8, 9, 10, 11, 12,
														13, 14, 15, 16, 17, 18,
														19, 20, 21, 22, 23, 24,
														25, 26, 27, 28, 29 ],
												/* "targets" : 29,
												"createdCell" : function(td,
														cellData, rowData, row,
														col) {
													if (cellData == 0) {
														$(td).parent().css(
																'color', 'red');
													}
												} */
											},

									],
									"columns" : [
											{
												"data" : "supplierEnterpriseNo",
												"defaultContent" : ""
											},
											{
												"data" : "enterpriseName",
												"defaultContent" : ""
											},
											{
												"data" : "enterpriseName",
												"defaultContent" : ""
											},
											{
												"data" : "inputCode",
												"defaultContent" : ""
											},
											{
												"data" : "supplierEnterpriseNo",
												"defaultContent" : ""
											},
											{
												"data" : "registerAddress",
												"defaultContent" : ""
											},
											{
												"data" : "linkman",
												"defaultContent" : ""
											},
											{
												"data" : "linkphone",
												"defaultContent" : ""
											},
											{
												"data" : "payAmount",
												"defaultContent" : ""
											},
											{
												"data" : "incomeAmount",
												"defaultContent" : ""
											},
											{
												"data" : "bankAccount",
												"defaultContent" : ""
											},
											{
												"data" : "bank",
												"defaultContent" : ""
											},
											{
												"data" : "dutyNo",
												"defaultContent" : ""
											},
											{
												"data" : "isAudit",
												"defaultContent" : ""
											},
											{
												"data" : "enterprisePhone",
												"defaultContent" : ""
											},
											{
												"data" : "postCode",
												"defaultContent" : "",

											},
											{
												"data" : "legalPerson",
												"defaultContent" : ""
											},
											{
												"data" : "licenseNo",
												"defaultContent" : ""
											},
											{
												"data" : "socialCreditCode",
												"defaultContent" : ""
											},
											{
												"data" : "manageType",
												"defaultContent" : ""
											},
											{
												"data" : "qualityDirecter",
												"defaultContent" : ""
											},
											{
												"data" : "ahrqPeopleCount",
												"defaultContent" : ""
											},
											{
												"data" : "nhrqContactWay",
												"defaultContent" : ""
											},
											{
												"data" : "certificateEndDate",
												"defaultContent" : "",
												"render" : function(data, type,
														full, meta) {
													return moment(data).format(
															"YYYY-MM-DD");
												}
											},
											{
												"data" : "certificateEndDate",
												"defaultContent" : "",
												"render" : function(data, type,
														full, meta) {
													return moment(data).format(
															"YYYY-MM-DD");
												}
											},
											{
												"data" : "entrustLimitedDate",
												"defaultContent" : "",
												"render" : function(data, type,
														full, meta) {
													return moment(data).format(
															"YYYY-MM-DD");
												}
											},
											{
												"data" : "qualityEndDate",
												"defaultContent" : "",
												"render" : function(data, type,
														full, meta) {
													return moment(data).format(
															"YYYY-MM-DD");
												}
											},
											{
												"data" : "certificateEndDate",
												"defaultContent" : "",
												"render" : function(data, type,
														full, meta) {
													return moment(data).format(
															"YYYY-MM-DD");
												}
											}, {
												"data" : "isAudit",
												"defaultContent" : ""
											}, {
												"data" : "status",
												"defaultContent" : ""
											} ]
								});
			}

		//判断当前有没选中行
		function getSelectedNoByForm(formId) {
			var object = null;
			$(formId).find("tr").each(function() {
				if ($(this).hasClass('selected')) {
					object = $(this).children("td").eq(0).text();
				}
			});
			return object;
		}

		function startUsing() {
			var supplier_no = getSelectedNoByForm("#providerList_table");
			if (supplier_no == null)
				return;
			layer
					.confirm(
							'确认要启用该供应商吗？',
							function(index) {
								$
										.ajax({
											type : "post",
											url : "/Medical_Instrument/firstEnterprise/startUsingProvider",
											data : {
												"supplier_no" : supplier_no
											},
											dataType : "json",
											success : function(data) {
												if (data.result == "success") {
													layer.msg('启用成功!', {
														icon : 6,
														time : 1000
													});
                                               init();
												} else {
													layer.msg('启用失败，请稍后再试！', {
														icon : 5,
														time : 1000
													});
												}

											},
											error : function(data) {
												layer.msg('请求失败!', {
													icon : 5,
													time : 1000
												});
											}
										});

							});
		}
		function blockUp() {
			var supplier_no = getSelectedNoByForm("#providerList_table");
			if (supplier_no == null)
				return;
			layer
					.confirm(
							'确认要停用该供应商吗？',
							function(index) {
								$
										.ajax({
											type : "post",
											url : "/Medical_Instrument/firstEnterprise/blockUpProvider",
											data : {
												"supplier_no" : supplier_no
											},
											dataType : "json",
											success : function(data) {
												if (data.result == "success") {
													layer.msg('停用成功!', {
														icon : 6,
														time : 1000
													});
                                                     init();
												} else {
													layer.msg('停用失败，请稍后再试！', {
														icon : 5,
														time : 1000
													});
												}

											},
											error : function(data) {
												layer.msg('请求失败!', {
													icon : 5,
													time : 1000
												});
											}
										});

							});
		}

		function blockUpAll() {
			layer
					.confirm(
							'确认要停用全部供应商吗？',
							function(index) {
								$
										.ajax({
											type : "post",
											url : "/Medical_Instrument/firstEnterprise/blockUpAllProvider",
											dataType : "json",
											success : function(data) {
												if (data.result == "success") {
													layer.msg('停用全部供应商成功!', {
														icon : 6,
														time : 1000
													});
                                                  init();
												} else {
													layer.msg('停用失败，请稍后再试！', {
														icon : 5,
														time : 1000
													});
												}

											},
											error : function(data) {
												layer.msg('请求失败!', {
													icon : 5,
													time : 1000
												});
											}
										});

							});
		}
	</script>
</body>

</html>